<?php
/**
 * Single Product Thumbnails
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     2.0.3
 */
if (!defined('ABSPATH'))
    exit; // Exit if accessed directly

global $post, $product, $woocommerce;

$attachment_ids = $product->get_gallery_attachment_ids();

if ($attachment_ids && count($attachment_ids)) {
    ?>
    <div id="carousel-example-generic" class="carousel slide hidden-sm shop-thumb">

        <!-- Wrapper for slides -->
        <div class="carousel-inner">
            <?php
            $loop = 0;
            $columns = apply_filters('woocommerce_product_thumbnails_columns', 3);

            foreach ($attachment_ids as $attachment_id) {

                $classes = array('zoom');

                    $classes[] = 'img-thumbnail';

                
                $image_link = get_mthumb_link($product->get_sku(), '356_520');;

                if (!$image_link)
                    continue;
                $imglink = get_mthumb_link($product->get_sku(), '146_168');
                $image = "<img src='$imglink' />"; 
                $image_class = esc_attr(implode(' ', $classes));
                $image_title = esc_attr(get_the_title());
                if(!$loop){
                     echo  '<div class="item active">' ;
                }else if(!($loop%3)){
                     echo  '<div class="item ">';
                }
               
                echo apply_filters('woocommerce_single_product_image_thumbnail_html', sprintf('<div class="col-4"><a href="javascript:void(0)" onclick="changefutureimg(\'%s\')"  class="%s" title="%s" >%s</a></div>', $image_link, $image_class, $image_title, $image), $attachment_id, $post->ID, $image_class);
                echo !(($loop + 1) % 3) ? '</div>' : '';
                $loop++;
            }
            echo ($loop % 3) ? '</div>' : '';
            ?>
        </div>
        <?php if($loop>=3||true){ ?>
        <!-- Controls -->
        <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
            <span class="icon-prev"></span>
        </a>
        <a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
            <span class="icon-next"></span>
        </a>
        <?php } ?>
    </div>


    <?php
}